﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XYTXL.API;
using XYTXL.Data;
using XYTXL.AppCode;

namespace XYTXL.Web.View.UCMangForm
{
    public partial class XXLR : FormUControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        public override void initALLForm(string strFormCode)
        {
            base.initALLForm(strFormCode);
            new CommonHelp.BindData().BindXM(ddlXM);
        }


        /// <summary>
        /// 新增时验证栏目重复
        /// </summary>
        /// <param name="strActionType"></param>
        /// <returns></returns>
        public override string VerifyAddForm(string strActionType)
        {

            return "";
        }
        /// <summary>
        /// 修改时验证栏目重复
        /// </summary>
        /// <param name="intFormID"></param>
        /// <param name="strActionType"></param>
        /// <returns></returns>
        public override string VerifyUpdateForm(int intFormID)
        {

            return "";
        }

        /// <summary>
        /// 重写父类的保存数据方法
        /// </summary>
        /// <param name="intFormID">数据ID</param>
        /// <param name="strActionType">操作类型("ADD":"添加","UPDATE":"修改")</param>
        /// <returns></returns>
        public override bool SaveForm(int intFormID, string strActionType, int pid)
        {
            //执行 父类的方法
            base.SaveForm(intFormID, strActionType);

            //保存数据
            xy_jzmx Model = new xy_jzmxB().GetEntity(d => d.ID == intFormID);
            Model.xmdm = ddlXM.SelectedValue;
            Model.xmmc = ddlXM.SelectedItem.Text;
            Model.jzlb = ddlType.SelectedValue;
            Model.je = decimal.Parse(txtJE.Text);
            Model.sm = txtSM.Text;
            Model.lxr = txtlxr.Text;
            Model.sfnm = ddlSFNM.SelectedValue;
            return new xy_jzmxB().Update(Model);
        }

        public override void initMangerForm(int intFormID, string strActionType)
        {
            base.initMangerForm(intFormID, strActionType);
            xy_jzmx Model = new xy_jzmxB().GetEntity(d => d.ID == intFormID);
            ddlXM.SelectedValue = Model.xmdm;
            ddlType.SelectedValue = Model.jzlb;
            txtJE.Text = Model.je.ToString();
            txtSM.Text = Model.sm;
            ddlSFNM.SelectedValue = Model.sfnm;
            txtlxr.Text = Model.lxr;
        }
    }
}